package com.bwsoft.action;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.bwsoft.domain.Dictionary;
import com.bwsoft.domain.DictionaryData;
import com.bwsoft.domain.Fun;
import com.bwsoft.domain.User;
import com.bwsoft.domain.UserGroup;
import com.bwsoft.model.ComBoBox;
import com.bwsoft.model.Message;
import com.bwsoft.service.DictionaryDataService;
import com.bwsoft.service.DictionaryService;
import com.bwsoft.service.FunService;
import com.bwsoft.service.SystemService;
import com.bwsoft.service.UserGroupService;
import com.bwsoft.service.UserService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class BaseAction extends ActionSupport {

	private static final long serialVersionUID = 7620009925942346125L;

	public ActionContext context = ActionContext.getContext();
	public HttpServletRequest request = (HttpServletRequest) context
			.get(ServletActionContext.HTTP_REQUEST);
	public HttpServletResponse response = (HttpServletResponse) context
			.get(ServletActionContext.HTTP_RESPONSE);
	public Map session = context.getSession();

	public Map responseJson = new HashMap<String, Object>();
	public List responseListJson = new ArrayList<Object>();

	public Integer page;
	public Integer rows;

	@Resource(name = UserService.NAME)
	public UserService userService;
	@Resource(name = FunService.NAME)
	public FunService funService;
	@Resource(name = SystemService.NAME)
	public SystemService systemService;
	@Resource(name = UserGroupService.NAME)
	public UserGroupService userGroupService;
	@Resource(name = DictionaryService.NAME)
	public DictionaryService dictionaryService;
	@Resource(name = DictionaryDataService.NAME)
	public DictionaryDataService dictionaryDataService;

	public User user;
	public Fun fun;
	public UserGroup userGroup;
	public Dictionary dictionary;
	public DictionaryData dictionaryData;
	public List<User> userList;
	public List<UserGroup> userGroupList;
	public List<Fun> funList;
	public List<Dictionary> dictionaryList;
	public List<DictionaryData> dictionaryDataList;
	public ComBoBox comBoBox;

	/**
	 * 用于传送一些消息
	 */
	public Message msg = new Message();

	public Message getMsg() {
		return msg;
	}

	public void setMsg(Message msg) {
		this.msg = msg;
	}

	public Map getResponseJson() {
		return responseJson;
	}

	public void setResponseJson(Map responseJson) {
		this.responseJson = responseJson;
	}

	public List getResponseListJson() {
		return responseListJson;
	}

	public void setResponseListJson(List responseListJson) {
		this.responseListJson = responseListJson;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Fun getFun() {
		return fun;
	}

	public void setFun(Fun fun) {
		this.fun = fun;
	}

	public UserGroup getUserGroup() {
		return userGroup;
	}

	public void setUserGroup(UserGroup userGroup) {
		this.userGroup = userGroup;
	}

	public List<User> getUserList() {
		return userList;
	}

	public void setUserList(List<User> userList) {
		this.userList = userList;
	}

	public List<UserGroup> getUserGroupList() {
		return userGroupList;
	}

	public void setUserGroupList(List<UserGroup> userGroupList) {
		this.userGroupList = userGroupList;
	}

	public List<Fun> getFunList() {
		return funList;
	}

	public void setFunList(List<Fun> funList) {
		this.funList = funList;
	}

	public Integer getPage() {
		if (rows == null || rows <= 0) {
			return 1;
		}
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Integer getRows() {
		if (rows == null || rows <= 0) {
			return 10;
		}
		return rows;
	}

	public void setRows(Integer rows) {
		this.rows = rows;
	}

	public ComBoBox getComBoBox() {
		return comBoBox;
	}

	public void setComBoBox(ComBoBox comBoBox) {
		this.comBoBox = comBoBox;
	}

	public Dictionary getDictionary() {
		return dictionary;
	}

	public void setDictionary(Dictionary dictionary) {
		this.dictionary = dictionary;
	}

	public DictionaryData getDictionaryData() {
		return dictionaryData;
	}

	public void setDictionaryData(DictionaryData dictionaryData) {
		this.dictionaryData = dictionaryData;
	}

}
